
import groovy.grape.Grape
Grape.grab(group:"org.apache.camel", module:"camel-core", version:"2.0.0")

class HelloProcessor implements org.apache.camel.Processor {
  void process(org.apache.camel.Exchange exchange) {
    exchange.in.body = "Hello ${exchange.in.body}, nice going."
  }
}

class MyRouteBuilder extends org.apache.camel.builder.RouteBuilder { 
  void configure() { 
    from("direct://foo").process(new HelloProcessor()).to("mock://result") 
  }
}

ctx = new org.apache.camel.impl.DefaultCamelContext()
mrb = new MyRouteBuilder()
ctx.addRoutes mrb
ctx.start()

p = ctx.createProducerTemplate()
p.sendBody "direct:foo", "Jack"

e = ctx.getEndpoint("mock://result")
e.exchanges.each { ex ->
  println "INFO> in.body='${ex.in.body}'"
}
